package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.VContactResultsApplication;
import com.ruoyi.system.service.IVContactResultsApplicationService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 基础2问题数据Controller
 * 
 * @author ruoyi
 * @date 2024-12-15
 */
@Controller
@RequestMapping("/system/VContactResultsApplication")
public class VContactResultsApplicationController extends BaseController
{
    private String prefix = "system/VContactResultsApplication";

    @Autowired
    private IVContactResultsApplicationService vContactResultsApplicationService;

    @RequiresPermissions("system:VContactResultsApplication:view")
    @GetMapping()
    public String VContactResultsApplication()
    {
        return prefix + "/VContactResultsApplication";
    }

    /**
     * 查询基础2问题数据列表
     */
    @RequiresPermissions("system:VContactResultsApplication:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(VContactResultsApplication vContactResultsApplication)
    {
        startPage();
        List<VContactResultsApplication> list = vContactResultsApplicationService.selectVContactResultsApplicationList(vContactResultsApplication);
        return getDataTable(list);
    }

    /**
     * 导出基础2问题数据列表
     */
    @RequiresPermissions("system:VContactResultsApplication:export")
    @Log(title = "基础2问题数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(VContactResultsApplication vContactResultsApplication)
    {
        List<VContactResultsApplication> list = vContactResultsApplicationService.selectVContactResultsApplicationList(vContactResultsApplication);
        ExcelUtil<VContactResultsApplication> util = new ExcelUtil<VContactResultsApplication>(VContactResultsApplication.class);
        return util.exportExcel(list, "基础2问题数据数据");
    }

    /**
     * 新增基础2问题数据
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存基础2问题数据
     */
    @RequiresPermissions("system:VContactResultsApplication:add")
    @Log(title = "基础2问题数据", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(VContactResultsApplication vContactResultsApplication)
    {
        return toAjax(vContactResultsApplicationService.insertVContactResultsApplication(vContactResultsApplication));
    }

    /**
     * 修改基础2问题数据
     */
    @RequiresPermissions("system:VContactResultsApplication:edit")
    @GetMapping("/edit/{contactId}")
    public String edit(@PathVariable("contactId") Long contactId, ModelMap mmap)
    {
        VContactResultsApplication vContactResultsApplication = vContactResultsApplicationService.selectVContactResultsApplicationByContactId(contactId);
        mmap.put("vContactResultsApplication", vContactResultsApplication);
        return prefix + "/edit";
    }

    /**
     * 修改保存基础2问题数据
     */
    @RequiresPermissions("system:VContactResultsApplication:edit")
    @Log(title = "基础2问题数据", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(VContactResultsApplication vContactResultsApplication)
    {
        return toAjax(vContactResultsApplicationService.updateVContactResultsApplication(vContactResultsApplication));
    }

    /**
     * 删除基础2问题数据
     */
    @RequiresPermissions("system:VContactResultsApplication:remove")
    @Log(title = "基础2问题数据", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(vContactResultsApplicationService.deleteVContactResultsApplicationByContactIds(ids));
    }
}
